package app_config

import (
	"fmt"
	"github.com/spf13/viper"
)

type AppConfig struct {
	MysqlConfig
	RedisConfig
	AliYunSms
	JwtConfig
	QiNiuConfig
}

type MysqlConfig struct {
	User     string
	Password string
	Host     string
	Port     int
	Database string
}

type RedisConfig struct {
	Addr     string
	Password string
	Db       int
}

type AliYunSms struct {
	AccessKey    string
	SecretKey    string
	RegionID     string
	SignName     string
	TemplateCode string
}

type JwtConfig struct {
	AccessKey  string
	ExpireTime int
}

type QiNiuConfig struct {
	Ak string
	Sk string
}

var AppConf AppConfig

func InitApp() {
	viper.SetConfigFile("../app_config/dev.yaml")
	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("配置文件读取失败")
		return
	}
	viper.Unmarshal(&AppConf)
}
